package code.hibernate.dao;

import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hibernate.HibernateException;
import code.hibernate.po.*;
import hibernate.HibernateBaseDAO;

/**
 * A data access object (DAO) providing persistence and search support for
 * KeyanCodetype entities. Transaction control of the save(), update() and
 * delete() operations can directly support Spring container-managed
 * transactions or they can be augmented to handle user-managed Spring
 * transactions. Each of these methods provides additional information for how
 * to configure it for the desired type of transaction control.
 * 
 * @see code_type.hibernate.po.KeyanCodetype
 * @author MyEclipse Persistence Tools
 */

public class CodetypeDAO extends HibernateBaseDAO {
	private static final Log log = LogFactory.getLog(CodetypeDAO.class);
	// property constants
	public static final String CODETYPENAME = "codetypename";
	HibernateBaseDAO dao=HibernateBaseDAO.getInstance();
	public void save(Object o) {
		try{
			dao.saveOrupdate(o);
		}
		catch(HibernateException e){
			 e.printStackTrace();
		}
	}

	public boolean delete(Object o){
		return dao.delete(o);
	}

	public Codetype findById(java.lang.Integer id) {
		log.debug("getting KeyanCodetype instance with id: " + id);
		try {
			Codetype instance = (Codetype) getSession().get(
					"cn.edu.qau.collegeoa.code.hibernate.po.KeyanCodetype", id);
			return instance;
		} catch (RuntimeException re) {
			log.error("get failed", re);
			throw re;
		}
	}

	public List findByProperty(String propertyName, Object value) {
		log.debug("finding KeyanCodetype instance with property: "
				+ propertyName + ", value: " + value);
		try {
			String queryString = "from KeyanCodetype as model where model."
					+ propertyName + "= ?";
			return dao.find(queryString);
		} catch (RuntimeException re) {
			log.error("find by property name failed", re);
			throw re;
		}
	}
	public List findAll() {
		log.debug("finding all KeyanCodetype instances");
		try {
			String queryString = "from KeyanCodetype";
			return dao.find(queryString);
		} catch (RuntimeException re) {
			log.error("find all failed", re);
			throw re;
		}
	}

}